home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HPAVC
/
HPAVC CD-ROM.iso
/
FNTPAK32.ZIP
/
BASIC.EXE
/
DEMOMOUS.BAS
< prev
next >
Wrap
BASIC Source File
|
1995-08-16
|
7KB
|
289 lines
DEFINT A-Z
'$INCLUDE: 'Font_Pak.Inc' '... For QB/PDS/VB-DOS
'======================================================== PowerBasic Users
''$INCLUDE "Font_Pak.Inc" '... PB users, UN-REM these lines
''$Link "FontPakP.OBJ" '... SHAREWARE users
''$Link "Video.OBJ" '... REGISTERED users
''$Link "Fonts.OBJ" ' " "
''$Link "Mouse_P.OBJ" ' " "
''$Link "LdCursor.Obj" ' " "
'======================================================== PowerBasic Users
'============================================================ DemoMous.Bas
'
' A Font Pak Demonstration Copyright 1991-1994 Rob W. Smetana
'
' - Demonstrate how to use a few mouse routines
' - Show how easy it is to re-map the mouse cursor shape
'
' Requires: - A mouse
'
' - Font_Pak.Lib (QB/PDS/VB-DOS) -or- Font_Pak.PBU (PowerBasic)
'
'============================================================ DemoMous.Bas
'==== Local Routines
DECLARE SUB ClearButtons ()
DECLARE SUB SetUpGrid ()
DECLARE SUB DoMouseDemo ()
DECLARE SUB DisplayButtons (Buttons%, PX%, PY%)
DECLARE SUB Normal ()
DECLARE SUB PrintMsg (PosX%, PosY%, PrintTxt$)
DECLARE SUB Reverse ()
ForeGround = 7: BackGround = 1
SCREEN 0, 0
WIDTH 80, 25 '...DON'T change this. This demo
' assumes you're in 25-line mode!
COLOR 7, 1: CLS
CALL fpInitialize: CLS '=== SHAREWARE versions ONLY
CALL DoMouseDemo
SUB ClearButtons
DO
'... the last 0 means return TEXT mode Row/Col rather than Pixels
Buttons = rsButtonPressed(MouseRow, MouseCol, 0)
LOOP WHILE Buttons
END SUB
SUB DisplayButtons (Buttons, PX, PY)
Reverse
LOCATE 24, 27: PRINT "Button(s) pressed: ";
SELECT CASE Buttons
CASE 1 'LeftButton
PRINT "Left ";
CASE 2 'RightButton
PRINT "Right ";
CASE 3 'Both Left AND RightButton
PRINT "Left & right ";
CASE 4
PRINT "Middle ";
'CASE ELSE
' PRINT "Unknown ";
END SELECT
LOCATE 24, 60: PRINT "Row="; PY; " Col="; PX;
Normal
END SUB
'
SUB DoMouseDemo
SHARED ForeGround, BackGround
Normal
CLS
IF rsThereIsAMouse = 0 THEN
PRINT
PRINT "Sorry, I couldn't find or initialize the mouse. I can't continue."
PRINT
EXIT SUB
END IF
'...display a grid
SetUpGrid
PrintMsg 24, 2, " A Mouse IS Installed."
'...load mouse shapes 1-4 into block 0, remapping ASCII slots 224-277
FOR MouseCharacter = 224 TO 227
CALL rsLoadMouseCursor(0, MouseCharacter - 223, MouseCharacter)
NEXT
'...set (select) ASCII 224
MouseCharacter = 224
'...this version of rsSetTextCursor lets you SELECT the FG/BG colors
CALL rsSetTextCursor(14, BackGround, MouseCharacter)
'...Part 1 of the demo
LOCATE 25, 2: Reverse: PRINT SPACE$(78);
LOCATE 25, 2, Zero
PRINT " Press the Left OR Right mouse buttons (or both). Press <Escape> to Quit.";
CALL rsShowcursor
ClearButtons
DO UNTIL INKEY$ = CHR$(27) '... exit on Escape
'...rsButtonPressed's final parameter (0) means return TEXT-mode Row/Col.
' Change "0" to -1 (or any non-0 value) to tell rsButtonPressed
' to return GRAPHICS-mode pixel coordinates. But do NOT do
' that here because we expect MouseRow and MouseCol to be in
' the range of 1-25 and 1-80, respectively.
Buttons = rsButtonPressed(MouseRow, MouseCol, 0)
'...If the mouse has moved, change cursor shape based on Row/Col
IF MouseRow <> LastRow OR MouseCol <> LastCol THEN
SELECT CASE MouseRow
CASE 1 TO 13
IF MouseCol < 41 THEN MouseCharacter = 224 ELSE MouseCharacter = 226
CASE ELSE
IF MouseCol < 41 THEN MouseCharacter = 225 ELSE MouseCharacter = 227
END SELECT
CALL rsSetTextCursor(14, BackGround, MouseCharacter)
END IF
'... Should we update the screen: Which button/Where the cursor is?
IF MouseRow <> LastRow OR MouseCol <> LastCol OR Buttons THEN
LastRow = MouseRow: LastCol = MouseCol
DisplayButtons Buttons, MouseCol, MouseRow
END IF
'...If a mouse button is pressed, CHANGE the COLOR of the cursor.
' The cursor WILL flicker if you hold a button down.
IF Buttons THEN
CALL rsSetTextCursor(15, 4, MouseCharacter)
'...rsSetTextCursorC INVERTS or USES FG/BG colors under the mouse
'CALL rsSetTextCursorC(-1, MouseCharacter) '-1 = Invert; 0 = Use
'...ClearButtons would eliminate flicker. But it also would
' prevent us from changing mouse shapes if you hold down a
' button and then move across a grid boundary.
'ClearButtons
END IF
LOOP
CALL rsHidecursor
'...Part 2 of the demo
ClearButtons
CLS
PRINT
PRINT " We just showed how you could re-map the shape of ASCII characters, then"
PRINT " use those shapes as mouse cursors."
PRINT
PRINT " But you can select ANY ASCII character, even though you haven't changed"
PRINT " shapes. Click either mouse button to see a few. <Escape> = QUIT"
CALL rsShowcursor
MouseCharacter = 1 '...start with ASCII 1
' try ASCII 223 - 254 as well
CALL rsSetTextCursor(14, BackGround, MouseCharacter)
DO UNTIL INKEY$ = CHR$(27) '... exit on Escape
'...the last 0 = TextOrPixels (return TEXT-mode Row/Col)
Buttons = rsButtonPressed(MouseRow, MouseCol, 0)
IF Buttons THEN
'...get next one (mapped from chr$(228) to chr$(245)
MouseCharacter = MouseCharacter + 1
IF MouseCharacter = 32 THEN MouseCharacter = 224
CALL rsSetTextCursor(14, BackGround, MouseCharacter)
'...wait until the button is released so we don't move too quickly
ClearButtons
END IF
LOOP
CALL rsHidecursor
END SUB
SUB Normal
SHARED ForeGround, BackGround
COLOR ForeGround, BackGround
END SUB
SUB PrintMsg (PosX, PosY, PrintTxt$)
Reverse
LOCATE PosX, PosY
PRINT LEFT$(PrintTxt$ + STRING$(50, " "), 50);
Normal
END SUB
SUB Reverse
SHARED ForeGround, BackGround
COLOR BackGround, ForeGround
END SUB
SUB SetUpGrid
PRINT " Move the mouse cursor around the CENTER of this grid."
PRINT " Watch what happens each time the cursor crosses a line!"
PRINT
PRINT " Also HOLD DOWN either mouse button, and then do the same."
LOCATE 13, 10: PRINT STRING$(60, 196)
FOR x = 7 TO 21: LOCATE x, 40: PRINT "│"; : NEXT
LOCATE 13, 40: PRINT CHR$(197)
Reverse
LOCATE 24, 2: PRINT SPACE$(78);
Normal
END SUB